package base.day26.udp;

import java.io.IOException;
import java.net.*;
import java.util.Scanner;

public class SendDemo {
    public static void main(String[] args) throws IOException {
        DatagramSocket ds = new DatagramSocket();
        Scanner sc=new Scanner(System.in);
        while (true){
            System.out.println("请输入：");
            String data=sc.next();
            if (data.equals("886")){
                break;
            }else {
                //创建数组接收数据
                byte[] bytes = data.getBytes();
                InetAddress name = InetAddress.getByName("SuperJohn");
                int port=10001;
                //将数据装进包里
                DatagramPacket dp = new DatagramPacket(bytes,bytes.length,name,port);
                ds.send(dp);
                //ds.close();


            }
        }



    }
}
